<?php

require_once ('classes/service/AuthServiceImpl.php');
require_once ('classes/service/TopicsServiceImpl.php');
require_once ('classes/service/UsersServiceImpl.php');
require_once ('classes/service/VotesServiceImpl.php');

class ServiceLocator {
	
	/**
	 * AuthService
	 *
	 * @var IAuthService
	 */
	private static $authService;
	
	public static function getAuthService() {
		if(ServiceLocator::$authService == null) {
			ServiceLocator::$authService = new AuthServiceImpl();
		}
		return ServiceLocator::$authService;
	}

	/**
	 * TopicsService
	 *
	 * @var ITopicsService
	 */
	private static $topicsService;
	
	/**
	 * @return ITopicsService
	 */
	public static function getTopicsService() {
		if(ServiceLocator::$topicsService == null) {
			ServiceLocator::$topicsService = new TopicsServiceImpl();
		}
		return ServiceLocator::$topicsService;
	}

	/**
	 * UsersService
	 *
	 * @var IUsersService
	 */
	private static $usersService;
	
	public static function getUsersService() {
		if(ServiceLocator::$usersService == null) {
			ServiceLocator::$usersService = new UsersServiceImpl();
		}
		return ServiceLocator::$usersService;
	}

	/**
	 * VotesService
	 *
	 * @var IVotesService
	 */
	private static $votesService;
	
	public static function getVotesService() {
		if(ServiceLocator::$votesService == null) {
			ServiceLocator::$votesService = new VotesServiceImpl();
		}
		return ServiceLocator::$votesService;
	}
	
}

?>